﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;

namespace Mido.Utils.Converters
{
	public class EnumBooleanConverter : MarkupExtension, IValueConverter
    {
        #region IValueConverter Members
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			return value.Equals(parameter);
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (value.Equals(false))
				return DependencyProperty.UnsetValue;

			return parameter;
		}

        #endregion

		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			return this;
		}
    }
}
